<template>
  <div>
      <Add @show="show"></Add>
      <Update @show="show"></Update>
      <List @show="show" :products="products"></List>
  </div>
</template>

<script>
import List from '../components/product/List'
import Add from '../components/product/Add'
import Update from '../components/product/Update'

import { getAll } from '../services/product'
export default {
    components:{List,Add,Update},
    data(){
        return {
            products:[],
            pagination:{}
        }
    },
    created(){
        this.show();
    },
    methods:{
         async show(current,pageSize,type,value){
            if(type){
                this.type = type;
                this.value = value;
            }
            let data = await getAll(current,pageSize,this.type,this.value);
            console.log('data',data)
            this.products = data.rows;
            this.pagination = {...this.pagination,...data,pageSize:data.size};
        }
    }
}
</script>

<style>

</style>